package com.chinasoft.maysham.manager.response;

import lombok.Data;

import java.io.Serializable;

@Data
public class Response<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private static final int SUCCESS = 200;
    private static final int ERROR = 500;

    private int status;

    private T result;

    private String error;

    public Response(int status, T result, String error) {
        this.status = status;
        this.result = result;
        this.error = error;
    }

    public static <T> Response<T> success(T t){
        return new Response<>(SUCCESS, t, null);
    }

    public static <T> Response<T> error(String error){
        return new Response<>(ERROR, null, error);
    }
}
